﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GRWL.BZSC.UI
{
    public partial class MainFrm : Form
    {
        //private int childFormNumber = 0;

        public MainFrm()
        {
            InitializeComponent();
            WindowState = FormWindowState.Maximized;
        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            TraderFrm frmSupplier = new TraderFrm();
            //frmSupplier.SetTraderAsSupplier();
            frmSupplier.IsSupplierType = true;
            frmSupplier.IsSupplier = true;
            frmSupplier.IsClient = false;
            //if (!Common.MdiFrmIsOpened(this, frmSupplier.Name))
            //{
                frmSupplier.MdiParent = this;
                frmSupplier.Show();
            //}
        }
  
        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

          private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void mMaterial_Click(object sender, EventArgs e)
        {
            Form frm = new MaterialFrm();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void mMaterialCategory_Click(object sender, EventArgs e)
        {
            OptionFrm frm = new OptionFrm();
            frm.Name = GRWL.BZSC.Common.EnumCommon.OptionType.物料分类.ToString();
            frm.OType = GRWL.BZSC.Common.EnumCommon.OptionType.物料分类;
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            //供应商分类
            OptionFrm frm = new OptionFrm();
            frm.Name = GRWL.BZSC.Common.EnumCommon.OptionType.供应商分类.ToString();
            frm.OType = GRWL.BZSC.Common.EnumCommon.OptionType.供应商分类;
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            //客户分类
            OptionFrm frm = new OptionFrm();
            frm.Name = GRWL.BZSC.Common.EnumCommon.OptionType.客户分类.ToString();
            frm.OType = GRWL.BZSC.Common.EnumCommon.OptionType.客户分类;
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            TraderFrm frmClient = new TraderFrm();
            frmClient.SetTraderAsClient();
            //if (!Common.MdiFrmIsOpened(this, frmClient.Name))
            //{
                frmClient.MdiParent = this;
                frmClient.Show();
            //}
        }

        private void toolStripMenuItem5_Click(object sender, EventArgs e)
        {
            //仓库分类
            OptionFrm frm = new OptionFrm();
            frm.Name = GRWL.BZSC.Common.EnumCommon.OptionType.仓库分类.ToString();
            frm.OType = GRWL.BZSC.Common.EnumCommon.OptionType.仓库分类;
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
            //仓库
            DepotFrm frm = new DepotFrm();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }

        }

        private void toolStripMenuItem6_Click(object sender, EventArgs e)
        {
            //质量问题
            QcOptionFrm frm = new QcOptionFrm();
            frm.SetTableAsPromble();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void toolStripMenuItem7_Click(object sender, EventArgs e)
        {
            //质量结果
            QcOptionFrm frm = new QcOptionFrm();
            frm.SetTableAsResult();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void 产品工程ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ProductProjectFrm frm = new ProductProjectFrm();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void toolStripMenuItem8_Click(object sender, EventArgs e)
        {
            //仓库单据分类
            OptionFrm frm = new OptionFrm();
            frm.Name = GRWL.BZSC.Common.EnumCommon.OptionType.单据分类.ToString();
            frm.OType = GRWL.BZSC.Common.EnumCommon.OptionType.单据分类;
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void 部门资料ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DeptFrm frm = new DeptFrm();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void optionsToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            //库存管理 - 入仓
            DepotInOutFrm frm = new DepotInOutFrm();
            frm.Name = GRWL.BZSC.Common.EnumCommon.BillType.CGSH.ToString();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.IOStatus = GRWL.BZSC.Common.EnumCommon.DepotIOStatus.采购收货;
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void 人员信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UserFrm frm = new UserFrm();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void 零星领料ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PickingLxFrm frm = new PickingLxFrm();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void 质检单ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //采购检验
            QCFrm frm = new QCFrm();
            frm.Name = QCFrm.CheckType.采购检验.ToString();
            frm.BillType = QCFrm.CheckType.采购检验;
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }

        }

        private void 采购单ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OrderFrm frm = new OrderFrm();
            frm.Name = BZSC.Common.EnumCommon.OrderTypes.CG.ToString();
            frm.OrderType = BZSC.Common.EnumCommon.OrderTypes.CG;
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void 报价管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            QuotationFrm frm = new QuotationFrm();
            //if (!Common.MdiFrmIsOpened(this, frm.Name))
            //{
                frm.MdiParent = this;
                frm.Show();
            //}
        }

        private void 订货单ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OrderFrm frm = new OrderFrm();
            frm.Name = BZSC.Common.EnumCommon.OrderTypes.DH.ToString();
            frm.OrderType = BZSC.Common.EnumCommon.OrderTypes.DH;
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void 采购发放ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //JjHuaFaFangFrm frm = new JjHuaFaFangFrm();
            //frm.BillType = JjHuaFaFangFrm.BillTypes.CG;
            //frm.MdiParent = this;
            //frm.Show();

        }

        private void 生产需求ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditRqrtFrm frm = new EditRqrtFrm();
            frm.RqrtType = GRWL.BZSC.Common.EnumCommon.RequirementType.SCXQ;
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void 生产ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ProductionFrm frm = new ProductionFrm();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void 需求发放ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IssueRqrtFrm frm = new IssueRqrtFrm();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void toolStripMenuItem9_Click(object sender, EventArgs e)
        {
            RequisitionFrm frm = new RequisitionFrm();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void btnQueryStockIO_Click(object sender, EventArgs e)
        {
            QueryStockIOFrm frm = new QueryStockIOFrm();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void 生产入库ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //ProductionStockInFrm frm = new ProductionStockInFrm();
            //if (!Common.MdiFrmIsOpened(this, frm.Name))
            //{
            //    frm.MdiParent = this;
            //    frm.Show();
            
            //}
            DepotInOutFrm frm = new DepotInOutFrm();
            frm.Name = GRWL.BZSC.Common.EnumCommon.BillType.SCSH.ToString();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.IOStatus = GRWL.BZSC.Common.EnumCommon.DepotIOStatus.生产收货;
                frm.MdiParent = this;
                frm.Show();
            }
        }

        private void btnQueryStockAmount_Click(object sender, EventArgs e)
        {
            QueryStockAmountFrm frm = new QueryStockAmountFrm();
            if (!Common.MdiFrmIsOpened(this, frm.Name))
            {
                frm.MdiParent = this;
                frm.Show();
            }

        }
 
    }
}
